﻿using System;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Linq;
using System.Text;
using PluginInterface;

namespace hlighttohtml
{
    class Plugins
    {
        public Hashtable plugins = new Hashtable();
        private string[] PluginList;

        public void FindPlugins()
        {
            PluginList = Directory.GetFiles(Environment.CurrentDirectory + "\\" + "Plugins", "*.dll", SearchOption.AllDirectories);
            foreach (string tmp in PluginList)
            {
                Assembly ass = Assembly.LoadFile(tmp);
                foreach (Type type in ass.GetTypes())
                {
                    Type intface = type.GetInterface("PluginInterface.IPlugin");
                    if (intface != null) 
                    {
                        IPlugin plugin = (IPlugin)Activator.CreateInstance(type);                        
                        plugins.Add(plugin.Extension, plugin);
                    }
                }                
            }
        }
    }
}
